<script type="text/javascript" src="/js/extlibs/jsTree/_lib/jquery.metadata.js"></script>
<script type="text/javascript" src="/js/extlibs/jsTree/_lib/css.js"></script>
<script type="text/javascript" src="/js/extlibs/jsTree/_lib/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/extlibs/jsTree/source/tree_component.js"></script>
<script type="text/javascript" src="/js/tests.tests.js"></script>
<script type="text/javascript" src="/js/tests.list.js"></script>
<script type="text/javascript" src="/js/tests.tree.js"></script>

<link rel="stylesheet" type="text/css" media="screen" href="/js/extlibs/jqGrid/themes/basic/grid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/js/extlibs/jqGrid/themes/jqModal.css" />

<script src="/js/extlibs/jqGrid/jquery.jqGrid.js" type="text/javascript"></script>
<script src="/js/extlibs/jqGrid/js/jqModal.js" type="text/javascript"></script>
<script src="/js/extlibs/jqGrid/js/jqDnR.js" type="text/javascript"></script>
<script src="/js/tests.formatters.js" type="text/javascript"></script>

<style>
<!--

.list-container {
  float: left;
  width: 500px;
  height: 400px;
  overflow: auto;
}

.content-container {
  margin-left: 510px;
  height: 400px;
  overflow: auto;
  padding:20px;
}

.test-list-title{
  width: 300px;
  padding-left: 30px;
}

#test-list{
  margin:10px;
}

.test-title{
  padding: 10px;
  background-color:#ccc;
  font-weight:normal;
}


.alert {
  background-color:#ee9;
}

.test-date{
  padding: 0 10px 0 10px;
  vertical-align: middle;
}

.related-tasks{
  color: #666;
}

.task-path{
  color: #666;
  font-size: 0.95em;
}

.task-path a:hover{
  cursor: pointer;
}

.test-table{
  color:#666;
}
.test-table th{
  text-align: left;
}
.test-table td{
  padding:1px 5px 1px 5px;
}
.test-table th{
  padding:1px 5px 1px 5px;
}

.test-days-old {
  padding: 0 10px 0 10px;
  vertical-align: middle;
}


.test-list-category{
  font-size: 14px;
  background-color:#ccc;
  border-bottom:solid 1px #999;
  padding: 2px 0px 2px 15px;
}

.test-list-dir{
  font-size: 14px;
  text-align:center;
  background-color:#bbb;
  padding: 15px 0px 15px 15px;
}

.test-list-item{
  clear: both;
  cursor: pointer;
  padding: 2px 0px 2px 0px;
}

.test-list-item2{
  clear: both;
  background: #ddd;
  cursor: pointer;
  padding: 2px 0px 2px 0px;
}

.test-list-headings{
  background: #bbb;
}

.test-list-item hover{
  background: #CCC;
}
-->
</style>

<script>
    <?php if($id): ?>
        var x = tests.list.gridComplete;
        tests.list.gridComplete.setId(<?php echo $id ?>);
    <?php endif; ?>
</script>

<?php include_partial('task/css') ?>
<?php include_partial('tests/menu'); ?><!-- vai pro slot -->

<h2 style='display:inline;'>Tests</h2>
<button type='button' id='search'><img src='/images/icons/search.png'/></a></button>
<table id="list" class="scroll"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>

<script type="text/javascript">


jQuery(document).ready(function(){
  jQuery("#list").jqGrid({
    url: '<?php echo url_for("tests/listTests"); ?>',
    datatype: 'json',
    mtype: 'GET',
    colNames:['dir','class', 'method','result','time','cre','imp','tsks','exists','cmd'],
    repeatitems: false,
    colModel :[
      {name:'dir', index:'dir', width:80},
      {name:'class', index:'class', width:200},
      {name:'method', index:'method', width:380},
      {name:'result', index:'result', width:90, formatter:tests.formatters.result},
      //{name:'file', index:'file', width:150, align:'right'},
      {name:'run_time', index:'run_time', width:50, align:'right', formatter:tests.formatters.time, search:false},
      {name:'days_test_last_import_time', index:'days_test_last_import_time', width:30, search:false},
      {name:'days_result_last_import_time', index:'days_result_last_import_time', width:30, formatter:tests.formatters.alert, formatoptions:{value:5}, search: false},
      {name:'numTasks', index:'numTasks', width:30, formatter:tests.formatters.alert, formatoptions:{type:'lesser',value:1},search:false},
      {name:'fileExists', index:'fileExists', width:30, formatter:tests.formatters.exists, search:false},
      {name:'id', index:'id', width:220, formatter:tests.formatters.cmd, search: false}
    ],
    pager: jQuery('#pager'),
    pgbutttons: false,
    rowNum:20,
    height: '450px',
    rowList:[20,50,100,300],
    sortname: 'id',
    sortorder: "desc",
    toolbar : [true,"top"],
    jsonReader: {
        repeatitems : false,
        id: "id"
    },
    ondblClickRow: function(id) {tests.tests.showTest({id:id});},
    viewrecords: true,
    imgpath: '/js/extlibs/jqGrid/themes/basic/images',
    caption: 'Unit Tests',
    gridComplete: tests.list.gridComplete
  });
  jQuery("#t_list").height(25).hide().filterGrid("list",{gridModel:true,gridToolbar:true});
  $("#search").bind('click',function() {
        if(jQuery("#t_list").css("display")=="none") {
            jQuery('#list').setGridParam({datatype:'json'});
            jQuery("#t_list").css("display","");
        } else {
            jQuery("#t_list").css("display","none");
        }
  });
});

</script>
